package tk.sunlatus.project.security.encode;

import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;

import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;

/**
 * EnCoder
 * 
 * @creator 悠忧虫
 * @create-time 2011-6-18 下午12:13:36
 * @revision 1.0
 */
public interface Encoder {

    /**
     * 对data进行加密
     * 
     * @param keyByte
     *            字节数组
     * @param data
     *            字节数组
     * @return 加密后的数据
     * @throws NoSuchAlgorithmException
     * @throws NoSuchPaddingException
     * @throws InvalidKeyException
     * @throws IllegalBlockSizeException
     * @throws BadPaddingException
     */
    byte[] encrypt(byte[] keyByte, byte[] data);

    /**
     * 对data进行加密
     * 
     * @param keyByte
     *            字节数组
     * @param data
     *            字符串
     * @return 加密后的数据
     * @throws NoSuchAlgorithmException
     * @throws NoSuchPaddingException
     * @throws InvalidKeyException
     * @throws IllegalBlockSizeException
     * @throws BadPaddingException
     */
    byte[] encrypt(byte[] keyByte, String data);

    /**
     * 对data进行加密
     * @param key Key
     * @param data 字节数组
     * @return
     * @throws NoSuchAlgorithmException
     * @throws NoSuchPaddingException
     * @throws InvalidKeyException
     * @throws IllegalBlockSizeException
     * @throws BadPaddingException
     */
    byte[] encrypt(Key key, byte[] data);

    /**
     * 
     * @param key Key
     * @param data 字符串
     * @return
     * @throws InvalidKeyException
     * @throws NoSuchAlgorithmException
     * @throws NoSuchPaddingException
     * @throws IllegalBlockSizeException
     * @throws BadPaddingException
     */
    byte[] encrypt(Key key, String data);
    
}
